<?php
class ORMPurchaseItem extends ORMBase {
  public function __construct() {
    parent::__construct('PurchaseItem');
  }

  public function __toEpObject($myManager, $epObject, $object) {
    require_once dirname(__FILE__) . '/ORMPurchaseItemSelect.class.php';
    require_once dirname(__FILE__) . '/ORMPurchaseNote.class.php';
    $epObject->trackId = isset($object->trackId) ? $object->trackId : '';
    $epObject->cancelled = isset($object->cancelled) ? $object->cancelled : 0;
    $epObject->sampleId = isset($object->sampleId) ? $object->sampleId : 0;
    $epObject->name = isset($object->name) ? $object->name : '';
    $epObject->price = isset($object->price) ? $object->price : 0;
    $epObject->unit = isset($object->unit) ? $object->unit : '';
    $epObject->type = isset($object->type) ? $object->type : '';
    $epObject->model = isset($object->model) ? $object->model : '';
    $epObject->otherId = isset($object->otherId) ? $object->otherId : '';
    if (isset($epObject->selects)) {
      $epObject->selects->removeAll();
      foreach ($object->selects as &$item) {
        $epObject->selects[] = $this->__getEpObject_4_lvl_1_object($myManager, $item, new ORMPurchaseItemSelect(), 'PurchaseItemSelect');
      }
    }
    $epObject->quantity = isset($object->quantity) ? $object->quantity : 0;
    $epObject->total = isset($object->total) ? $object->total : 0;
    $epObject->packageInc = isset($object->packageInc) ? $object->packageInc : '';
    $epObject->isFree = isset($object->isFree) ? $object->isFree : 0;
    if (isset($epObject->notes)) {
      $epObject->notes->removeAll();
      foreach ($object->notes as &$item) {
        $epObject->notes[] = $this->__getEpObject_4_lvl_1_object($myManager, $item, new ORMPurchaseNote(), 'PurchaseNote');
      }
    }
    $epObject->urgent = isset($object->urgent) ? $object->urgent : 0;
    return $epObject;
  }

  public function __toObject($myManager, $epObject, $object) {
    require_once dirname(__FILE__) . '/ORMPurchaseItemSelect.class.php';
    require_once dirname(__FILE__) . '/ORMPurchaseNote.class.php';
    $object->id = $epObject->oid;
    $object->trackId = $epObject->trackId;
    $object->cancelled = $epObject->cancelled;
    $object->sampleId = $epObject->sampleId;
    $object->name = $epObject->name;
    $object->price = $epObject->price;
    $object->unit = $epObject->unit;
    $object->type = $epObject->type;
    $object->model = $epObject->model;
    $object->otherId = $epObject->otherId;
    $object->selects = array();
    if (isset($epObject->selects)) {
      foreach ($epObject->selects as &$item) {
        $object->selects[] = $this->__getObject_4_lvl_1_ep_object($myManager, $item, new ORMPurchaseItemSelect());
      }
    }
    $object->quantity = $epObject->quantity;
    $object->total = $epObject->total;
    $object->packageInc = $epObject->packageInc;
    $object->isFree = $epObject->isFree;
    $object->notes = array();
    if (isset($epObject->notes)) {
      foreach ($epObject->notes as &$item) {
        $object->notes[] = $this->__getObject_4_lvl_1_ep_object($myManager, $item, new ORMPurchaseNote());
      }
    }
    $object->urgent = $epObject->urgent;
    return $object;
  }
}
?>
